package com.hnkywl.sts.entity.xsgl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.base.Sjzdz;
import com.hnkywl.sts.entity.cggl.Cgd;
import com.hnkywl.sts.entity.cggl.Cgdmx;
import com.hnkywl.sts.entity.htgl.Cght;
import com.hnkywl.sts.entity.jhgl.Bgjhmx;
import com.hnkywl.sts.entity.organ.Ck;
import com.hnkywl.sts.entity.organ.Gsjg;
import com.hnkywl.sts.entity.sys.Gg;
import org.hibernate.annotations.*;

import javax.persistence.Entity;
import javax.persistence.*;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

/**
 * 说明：卡号
 * 包:        com.hnkywl.sts.entity.xsgl
 * 类描述:    卡号
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Entity
@Table(name = "T_BIZ_KH")
@Where(clause = "deleted!='1'")
public class Kh extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqKh", allocationSize = 1, sequenceName = "SEQ_BIZ_KH")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqKh")
    private Long id;

    /**
     * 卡号编码
     */
    private String khbm;

    /**
     * 入库单号
     */
    private String rkdh;

    /**
     * 具体物资
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "JTWZ_ID")
    private Gg jtwz;

    /**
     * 产地
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CD_SJZDZ_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Sjzdz cd;

    /**
     * 销售明细
     */
    @OneToMany(fetch = FetchType.LAZY, targetEntity = Xsmx.class)
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn(name = "KH_ID")
    @Where(clause = "deleted!='1'")
    private List<Xsmx> xsmxList;


    /**
     * 入库数量
     */
    private Double rksl;

    /**
     * 数量
     */
    private Double sl;
    /**
     * 长度
     */
    private Double chd;
    /**
     * 件数
     */
    private Integer js;
    /**
     * 入库件数件数
     */
    private Integer rkjs;
    /**
     * 件重
     */
    private Double jz;
    /**
     * 可开单数量
     */
    private Double kkdsl;

    /**
     * 初始化数量  （记录入库的数量）
     */
    private Double cshsl;

    /**
     * 初始化件数  (记录入库的件数)
     */
    private Integer cshjs;

    /**
     * 计划数量   （记录申报数量）
     */
    private Double jhsl;

    /**
     * 计划件数    （记录申报件数）
     */
    private Integer jhjs;

    /**
     * 挂单数量   （记录挂单数量）
     */
    private Double gdsl;

    /**
     * 挂单件数   （记录挂单件数）
     */
    private Integer gdjs;
    /**
     * 临时数量
     */
    private transient Double lssl;
    /**
     * 临时件数
     */
    private transient Integer lsjs;

    /**
     * 挂单数量合计   （记录挂单数量）
     */
    private Double gdslhj = 0.0;

    /**
     * 挂单件数合计   （记录挂单件数）
     */
    private Integer gdjshj;

    /**
     * 含税单价
     */
    private Double wsdj;

    /**
     * 含税金额(实际单价*数量)
     */
    @Formula("xsxt_price*sl")
    private Double wsje;

    /**
     * 仓库
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CK_ID")
    private Ck ck;

    /**
     * 质量情况
     */
    private String zlqk;

    /**
     * 入库日期
     */
    private Date rkrq;

    /**
     * 出库日期
     */
    private Date ckrq;

    /**
     * 采购合同
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGHT_ID")
    private Cght cght;

    /**
     * 采购单
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGD_ID")
    private Cgd cgd;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGDMX_ID")
    private Cgdmx cgdmx;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "BGJHMX_ID")
    private Bgjhmx bgjhmx;


    private Integer pxh;

    @Formula("(select t.bj from T_BIZ_KCBJ t where t.KC_ID=(select a.id from T_BIZ_KC a where a.GG_ID=JTWZ_ID and a.BJGS_ID=(select y.ZGJG_ID from T_SYS_YG y where y.ID=CREATEUSER_ID)) and t.BJRQ=sysdate)")
    private Double kcbj;

    //备注
    private String bz;
    //清卡
    private Boolean qk = false;

    /**
     * 申报公司
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBGS_ID")
    private Gsjg sbgs;

    /**
     * 申报部门
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBBM_ID")
    private Gsjg sbbm;

    //采购公司
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGGS_ID")
    private Gsjg cggs;

    //供应商
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "GYS_ID")
    private Gsjg gys;

    //控货单价
    private Double khdj;

    // 加工状态，为0或者空：未加工，1：已经加工
    private String jgzt;

    //标示符
    private String sku;

    //销售系统销售单号
    private String xsxt_xsdh;

    //销售系统销售价格
    private Double xsxt_price;

    //销售系统发货日期
    private Date xsxt_fhrq;

    //销售系统号
    private String xsxt_htbm;
    //车号
    private String carNo;
    //捆包号
    private String bindNo;

    private String resource_serial_number_1;

    // 是否导入了实际价格 0:否，1：是
    private String sfdrjg;

    // 数据来源 0:仓储，1：销售系统
    private String sjly;
    private int ybc;

    public String getSjly() {
        return sjly;
    }

    public void setSjly(String sjly) {
        this.sjly = sjly;
    }

    public String getSfdrjg() {
        return sfdrjg;
    }

    public void setSfdrjg(String sfdrjg) {
        this.sfdrjg = sfdrjg;
    }

    public String getResource_serial_number_1() {
        return resource_serial_number_1;
    }

    public void setResource_serial_number_1(String resource_serial_number_1) {
        this.resource_serial_number_1 = resource_serial_number_1;
    }

    public String getXsxt_htbm() {
        return xsxt_htbm;
    }

    public void setXsxt_htbm(String xsxt_htbm) {
        this.xsxt_htbm = xsxt_htbm;
    }

    public String getCarNo() {
        return carNo;
    }

    public void setCarNo(String carNo) {
        this.carNo = carNo;
    }

    public String getBindNo() {
        return bindNo;
    }

    public void setBindNo(String bindNo) {
        this.bindNo = bindNo;
    }

    public String getXsxt_xsdh() {
        return xsxt_xsdh;
    }

    public void setXsxt_xsdh(String xsxt_xsdh) {
        this.xsxt_xsdh = xsxt_xsdh;
    }

    public Double getXsxt_price() {
        return xsxt_price;
    }

    public void setXsxt_price(Double xsxt_price) {
        this.xsxt_price = xsxt_price;
    }

    public Date getXsxt_fhrq() {
        return xsxt_fhrq;
    }

    public void setXsxt_fhrq(Date xsxt_fhrq) {
        this.xsxt_fhrq = xsxt_fhrq;
    }

    public Integer getPxh() {
        return pxh;
    }

    public void setPxh(Integer pxh) {
        this.pxh = pxh;
    }

    public String getSku() {
        return sku;
    }

    public void setSku(String sku) {
        this.sku = sku;
    }

    public Double getJhsl() {
        return jhsl;
    }

    public void setJhsl(Double jhsl) {
        this.jhsl = jhsl;
    }

    public Integer getJhjs() {
        return jhjs;
    }

    public void setJhjs(Integer jhjs) {
        this.jhjs = jhjs;
    }

    public Double getGdslhj() {
        return gdslhj;
    }

    public void setGdslhj(Double gdslhj) {
        this.gdslhj = gdslhj;
    }

    public Integer getGdjshj() {
        return gdjshj;
    }

    public void setGdjshj(Integer gdjshj) {
        this.gdjshj = gdjshj;
    }

    public Gsjg getGys() {
        return gys;
    }

    public void setGys(Gsjg gys) {
        this.gys = gys;
    }

    public Integer getGdjs() {
        return gdjs;
    }

    public void setGdjs(Integer gdjs) {
        this.gdjs = gdjs;
    }

    public Double getGdsl() {
        return gdsl;
    }

    public void setGdsl(Double gdsl) {
        this.gdsl = gdsl;
    }

    public Double getCshsl() {
        return cshsl;
    }

    public void setCshsl(Double cshsl) {
        this.cshsl = cshsl;
    }

    public Integer getCshjs() {
        return cshjs;
    }

    public void setCshjs(Integer cshjs) {
        this.cshjs = cshjs;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getKhbm() {
        return khbm;
    }

    public void setKhbm(String khbm) {
        this.khbm = khbm;
    }

    public String getRkdh() {
        return rkdh;
    }

    public void setRkdh(String rkdh) {
        this.rkdh = rkdh;
    }

    public Gg getJtwz() {
        return jtwz;
    }

    public void setJtwz(Gg jtwz) {
        this.jtwz = jtwz;
    }

    public Sjzdz getCd() {
        return cd;
    }

    public void setCd(Sjzdz cd) {
        this.cd = cd;
    }

    public List<Xsmx> getXsmxList() {
        return xsmxList;
    }

    public void setXsmxList(List<Xsmx> xsmxList) {
        this.xsmxList = xsmxList;
    }

    public Double getSl() {
        return sl;
    }

    public void setSl(Double sl) {
        this.sl = sl;
    }

    public Double getChd() {
        return chd;
    }

    public void setChd(Double chd) {
        this.chd = chd;
    }

    public Integer getJs() {
        return js;
    }

    public void setJs(Integer js) {
        this.js = js;
    }

    public Double getJz() {
        return jz;
    }

    public void setJz(Double jz) {
        this.jz = jz;
    }

    public Double getKkdsl() {
        return kkdsl;
    }

    public void setKkdsl(Double kkdsl) {
        this.kkdsl = kkdsl;
    }

    public Double getWsdj() {
        return wsdj;
    }

    public void setWsdj(Double wsdj) {
        this.wsdj = wsdj;
    }

    public Double getWsje() {
        return wsje;
    }

    public void setWsje(Double wsje) {
        this.wsje = wsje;
    }

    public Ck getCk() {
        return ck;
    }

    public void setCk(Ck ck) {
        this.ck = ck;
    }

    public String getZlqk() {
        return zlqk;
    }

    public void setZlqk(String zlqk) {
        this.zlqk = zlqk;
    }

    public Date getRkrq() {
        return rkrq;
    }

    public void setRkrq(Date rkrq) {
        this.rkrq = rkrq;
    }

    public Cgd getCgd() {
        return cgd;
    }

    public void setCgd(Cgd cgd) {
        this.cgd = cgd;
    }

    public Double getKcbj() {
        return kcbj;
    }

    public void setKcbj(Double kcbj) {
        this.kcbj = kcbj;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public Boolean getQk() {
        return qk;
    }

    public void setQk(Boolean qk) {
        this.qk = qk;
    }


    public Gsjg getSbgs() {
        return sbgs;
    }

    public void setSbgs(Gsjg sbgs) {
        this.sbgs = sbgs;
    }

    public Gsjg getSbbm() {
        return sbbm;
    }

    public void setSbbm(Gsjg sbbm) {
        this.sbbm = sbbm;
    }

    public Gsjg getCggs() {
        return cggs;
    }

    public void setCggs(Gsjg cggs) {
        this.cggs = cggs;
    }

    public Cgdmx getCgdmx() {
        return cgdmx;
    }

    public void setCgdmx(Cgdmx cgdmx) {
        this.cgdmx = cgdmx;
    }

    public Bgjhmx getBgjhmx() {
        return bgjhmx;
    }

    public void setBgjhmx(Bgjhmx bgjhmx) {
        this.bgjhmx = bgjhmx;
    }

    public Double getKhdj() {
        return khdj;
    }

    public void setKhdj(Double khdj) {
        this.khdj = khdj;
    }

    public String getJgzt() {
        return jgzt;
    }

    public void setJgzt(String jgzt) {
        this.jgzt = jgzt;
    }

    public Integer getLsjs() {
        return lsjs;
    }

    public void setLsjs(Integer lsjs) {
        this.lsjs = lsjs;
    }

    public Double getLssl() {
        return lssl;
    }

    public void setLssl(Double lssl) {
        this.lssl = lssl;
    }

    public Double getRksl() {
        return rksl;
    }

    public void setRksl(Double rksl) {
        this.rksl = rksl;
    }

    public Date getCkrq() {
        return ckrq;
    }

    public void setCkrq(Date ckrq) {
        this.ckrq = ckrq;
    }

    public Integer getRkjs() {
        return rkjs;
    }

    public void setRkjs(Integer rkjs) {
        this.rkjs = rkjs;
    }

    public Cght getCght() {
        return cght;
    }

    public void setCght(Cght cght) {
        this.cght = cght;
    }

    public int getYbc() {
        return ybc;
    }

    public void setYbc(int ybc) {
        this.ybc = ybc;
    }
}
